unit Unit46; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, Unit1;

type

  { TForm46 }

  TForm46 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormShow();
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form46: TForm46; 

implementation

{ TForm46 }

procedure TForm46.Button1Click(Sender: TObject);
var
  QueryString : String;
  
begin
  QueryString := 'insert into funcionario(fnc_nombre, fnc_descripcion) values('''
    + Edit1.Text + ''', ''' + ComboBox1.Text + ''')';
    
  Form1.PQConnection1.ExecuteDirect('begin work;');
  Form1.PQConnection1.ExecuteDirect(QueryString);
  Form1.PQConnection1.ExecuteDirect('commit work;');
  
  ShowMessage('ALTA EXITOSA');

  FormShow;
end;

procedure TForm46.Button2Click(Sender: TObject);
begin
  Close;
end;

procedure TForm46.FormShow();
begin
  Edit1.Text := '';
  ComboBox1.Text := '';
  
  Edit1.SetFocus;
end;

initialization
  {$I unit46.lrs}

end.

